package exemplo.teste;

import java.util.List;

import junit.framework.Assert;

import org.junit.Test;

import exemplo.database.LoginDAO;
import exemplo.database.ProductDAO;
import exemplo.database.SaleDAO;
import exemplo.model.Sale;

public class SalesDAOTest {

		@Test
	public void testAdd() throws Exception{
		System.out.println("add");
		ProductDAO prodDAO = new ProductDAO();
		LoginDAO vendorDAO = new LoginDAO();
		SaleDAO saleDAO = new SaleDAO();
		Sale sale = new Sale();
		sale.setAddress("address test");
		sale.setPrice(12.4f);
		sale.setCode(100);
		sale.setProduct(prodDAO.getByCode(1));
		sale.setVendor(vendorDAO.getById(1));
		boolean b = saleDAO.add(sale);
		Assert.assertEquals(true, b);
	}

	@Test
	public void testDelete() throws Exception{
		System.out.println("delete");
		ProductDAO prodDAO = new ProductDAO();
		LoginDAO vendorDAO = new LoginDAO();
		SaleDAO saleDAO = new SaleDAO();
		Sale sale = new Sale();
		sale.setAddress("address test");
		sale.setCode(100);
		sale.setProduct(prodDAO.getByCode(1));
		sale.setVendor(vendorDAO.getById(1));
		boolean b = saleDAO.delete(sale);
		Assert.assertEquals(true, b);
	}

	@Test
	public void testGetSales() throws Exception{
		System.out.println("getSales");
		SaleDAO saleDAO = new SaleDAO();
		List<Sale> list = saleDAO.getSales();
		Assert.assertTrue(list.size() == 1);

	}

}
